package com.sushi.dao.impl;

import com.alibaba.druid.pool.DruidDataSource;
import com.sushi.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.sql.DataSource;

@Repository("studentDao")
@Scope("singleton")
public class StudentDaoImpl implements StudentDao {

    @Autowired
    @Qualifier("dataSource")
    private DataSource ds;

    @Override
    public void show() {
        System.out.println("I'm a student!");
        System.out.println("ds" + ds);
    }
    @PostConstruct
    public void init() {
        System.out.println("初始化");
    }
    @PreDestroy
    public void destroy() {
        System.out.println("被销毁了");
    }
}
